/*layui 各组件初始化*/

let table = layui.table;

/* table options 初始化参数*/
table.set({
    method: 'post',
    contentType: 'application/json',
    page: true,
    toolbar: '#LAY-table-bar',
    defaultToolbar: [],
    text: {
        none: '无数据'
    },
    initSort: {
        field: 'id',
        type: 'asc'
    },
    // 表格外观 line | row | nob
    skin: 'row',
    // 开启隔行背景
    even: true,
    request: {
        pageName: 'current',
        limitName: 'size',
        whereName: 'query'
    },
    parseData: function (res) {
        return {
            "code": res.code,
            "msg": res.message,
            "count": res.data.total,
            "data": res.data.records
        };
    }
});

/* 弹出层 options 初始化参数*/
layer.config({
    anim: 5,//动画
    // skin: 'layui-layer-hui',
    closeBtn: 0, // 关闭右上角按钮
    shade: '0.3',
    isOutAnim: true, // 关闭动画
    resize: true,
    scrollbar: false,
    btnAlign:'r',
    end: function () {
        console.log('弹出层销毁回调.');
        $('#LAY-form').addClass('layui-hide');
    }
});

/* ajax 初始化参数*/
$.ajaxSetup({
    contentType: 'application/json',
    dataType: "json",
    beforeSend: function (req) {
        req.setRequestHeader("access_token", window.localStorage.getItem('access_token'));
    }
});